package com.myproject.yunPan.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.myproject.yunPan.common.CronTasks;
import com.myproject.yunPan.common.DirWatcher;
import com.myproject.yunPan.context.BackupContextHolder;
import com.myproject.yunPan.entity.Backup;
import com.myproject.yunPan.service.BackupTaskService;

@Service
public class BackupTaskServiceImpl implements BackupTaskService {

	@Override
	public void addBackupTask(Backup backup) {
		 BackupContextHolder.addBackup(backup);
         //设置定时任务
         CronTasks.setTimeTask(backup);
         //设置目录检测
         DirWatcher.setWatchMonitor(backup);
		
	}

	@Override
	public List<Backup> getAllTasks() {	
		return BackupContextHolder.getBackupList();
	}

	@Override
	public int deleteTask(Integer id) {
		BackupContextHolder.delBackup(id);
		return 0;
	}

	@Override
	public int updateTask(Backup backup) {
		BackupContextHolder.updateBackup(backup);
		return 0;
	}
	
	
	
	
	
	

	

}
